package ym.controller.patient;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;
import ym.pojo.*;
import ym.service.PatientService;
import ym.vo.BaseResult;

import java.util.List;

/**
 * 患者接口
 */
@CrossOrigin
@RestController
@RequestMapping("/front/patient")
public class FrontPatientCon {
    @DubboReference
    private PatientService patientService;

    /**
     * 新增
     *
     * @param patient
     * @return 执行结果
     */
    @PostMapping("/add")
    public BaseResult add(Patient patient) {
        patientService.add(patient);
        return BaseResult.ok();
    }


    /**
     * 修改
     *
     * @param patient
     * @return 执行结果
     */
    @PostMapping("/update")
    public BaseResult update(Patient patient) {
        patientService.update(patient);
        return BaseResult.ok();
    }


    /**
     * 删除
     *
     * @param patientId
     * @return 执行结果
     */
    @DeleteMapping("/delete")
    public BaseResult delete(Integer patientId) {
        patientService.delete(patientId);
        return BaseResult.ok();
    }


    /**
     * 根据id查询
     *
     * @param patientId
     * @return 查询结果
     */
    @GetMapping("/findById")
    public BaseResult findById(Integer patientId) {
        Patient patient = patientService.findById(patientId);
        return BaseResult.ok(patient);
    }

    /**
     * 查询所有
     *
     * @return
     */
    @GetMapping("/findAll")
    public BaseResult findAll() {
        List<Patient> all = patientService.findAll();
        return BaseResult.ok(all);
    }

    /**
     * 分页查询
     *
     * @param search 搜索条件
     * @param page   当前页
     * @param size   每页大小
     * @return
     */
    @GetMapping("/search")
    public BaseResult search(String search, int page, int size) {
        Page<Patient> patientPage = patientService.search(search, page, size);
        return BaseResult.ok(patientPage);
    }

    /**
     * NRS-2002评估【模拟测试版】
     *
     * @param patientId
     * @return
     */
    @GetMapping("/nrs2002Assessment")
    public BaseResult nrs2002Assessment(Integer patientId) {
        String score = patientService.nrs2002Assessment(patientId);
        return BaseResult.ok(score);
    }

    /**
     * MUST评估【模拟测试版】
     *
     * @param patientId
     * @return
     */
    @GetMapping("/mustAssessment")
    public BaseResult mustAssessment(Integer patientId) {
        String score = patientService.mustAssessment(patientId);
        return BaseResult.ok(score);
    }

    /**
     * NRS-2002评估[外置ai版]
     *
     * @param patientId
     * @return
     */
    @GetMapping("/nrs2002AssessmentWebAi")
    public BaseResult nrs2002AssessmentWebAi(Integer patientId, String totalScore, String assessmentResult) {
        patientService.nrs2002AssessmentWebAi(patientId, totalScore, assessmentResult);
        return BaseResult.ok();
    }

    /**
     * MUST评估[外置ai版]
     *
     * @param patientId
     * @return
     */
    @GetMapping("/mustAssessmentWebAi")
    public BaseResult mustAssessmentWebAi(Integer patientId, String totalScore, String assessmentResult) {
        patientService.mustAssessmentWebAi(patientId, totalScore, assessmentResult);
        return BaseResult.ok();
    }

    /**
     * 生成计划【模拟测试版】
     *
     * @param patientId
     * @return
     */
    @GetMapping("/generatePlan")
    public BaseResult generatePlan(Integer patientId) {
        patientService.generatePlan(patientId);
        return BaseResult.ok();
    }

    /**
     * 生成计划-计划【外置ai版】
     *
     * @param nutritionPlan
     * @return
     */
    @GetMapping("/generatePlanAiForNutritionPlan")
    public BaseResult generatePlanAiForNutritionPlan(NutritionPlan nutritionPlan) {
        Integer integer = patientService.generatePlanAiForNutritionPlan(nutritionPlan);
        return BaseResult.ok(integer);
    }

    /**
     * 生成计划-膳食方案【外置ai版】
     *
     * @param mealPlan
     * @return
     */
    @GetMapping("/generatePlanAiForMealPlan")
    public BaseResult generatePlanAiForMealPlan(MealPlan mealPlan) {
        Integer integer = patientService.generatePlanAiForMealPlan(mealPlan);
        return BaseResult.ok(integer);
    }

    /**
     * 生成计划-肠内营养方案【外置ai版】
     *
     * @param enteralNutritionPlan
     * @return
     */
    @GetMapping("/generatePlanAiForEnteralNutritionPlan")
    public BaseResult generatePlanAiForEnteralNutritionPlan(EnteralNutritionPlan enteralNutritionPlan) {
        Integer integer = patientService.generatePlanAiForEnteralNutritionPlan(enteralNutritionPlan);
        return BaseResult.ok(integer);
    }

    /**
     * 生成计划-肠外营养方案【外置ai版】
     *
     * @param parenteralNutritionPlan
     * @return
     */
    @GetMapping("/generatePlanAiForParenteralNutritionPlan")
    public BaseResult generatePlanAiForParenteralNutritionPlan(ParenteralNutritionPlan parenteralNutritionPlan) {
        Integer integer = patientService.generatePlanAiForParenteralNutritionPlan(parenteralNutritionPlan);
        return BaseResult.ok(integer);
    }
}
